package com.wwwarehouse.resource_center.fragment.createobject.createstore;

import android.os.Bundle;
import android.view.View;

import com.wwwarehouse.common.activity.base.BaseActivity;
import com.wwwarehouse.common.bean.response.CommonClass;
import com.wwwarehouse.resource_center.R;
import com.wwwarehouse.resource_center.customView.AutoClickButton;
import com.wwwarehouse.resource_center.customView.FilterEdittext;
import com.wwwarehouse.resource_center.eventbus_event.StringEvent;
import com.wwwarehouse.resource_center.fragment.rules.TheParentFragment;

import de.greenrobot.event.EventBus;

/**
 * Description: 添加店铺名称
 * Copyright  : Copyright (c) 2017
 * Author     : yfwang
 * Date       : 2017/9/7 14:28
 */

public class StoreAddNameFragment extends TheParentFragment {

    private AutoClickButton mBtn;
    private FilterEdittext mEtText;

    @Override
    protected int getContentId() {
        return R.layout.fragment_store_add_name;
    }

    @Override
    public void setTitle() {
        if (peekFragment() instanceof StoreAddNameFragment)
            mActivity.setTitle(getString(R.string.store_add_name));
    }

    @Override
    protected void init(View view) {
        mBtn = findView(view, R.id.confirm_btn);
        mEtText = findView(view, R.id.set_rule_name);
        mBtn.bindEditText(mEtText);
        Bundle bundle = getArguments();

        if (bundle != null) {
            String name = bundle.getString("name");
            if (name != null && !name.isEmpty())
                mEtText.setText(name);
        }

        ((BaseActivity) mActivity).hideSoftByEditViewIds(new int[]{R.id.set_rule_name});
    }

    @Override
    protected void loadDatas() {
        mBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EventBus.getDefault().post(new StringEvent("create_store_name", mEtText.getText().toString()));
            }
        });
    }

    @Override
    public void onSuccess(CommonClass commonClass, int what) {

    }

    @Override
    public void onReLoad(int code) {

    }


}
